package com.test.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.test.ssm.pojo.Feedback;
import com.test.ssm.pojo.Teacher;
import com.test.ssm.service.FeedbakService;
import com.test.ssm.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

/**
 * @author 徒有琴
 */
@Controller
@RequestMapping("/teacher")
public class TeacherController {
    @Autowired
    private FeedbakService feedbakService;

    @RequestMapping("/index.html")
    public String index() {
        return "/teacher/index";
    }

    @RequestMapping("/attendance.html")
    public String attendance() {
        return "/teacher/attendance";
    }

    @RequestMapping("/student.html")
    public String student() {
        return "/teacher/student";
    }

    @RequestMapping("/feedback.html")
    @ResponseBody
    public PageInfo<Feedback> feedback(HttpSession session, Integer pageNum, Integer classId, String stuName) {
        if (pageNum == null || pageNum < 1) {
            pageNum = 1;
        }
        Teacher teacher = (Teacher) session.getAttribute(Constants.SESSION_USER);
        return feedbakService.getFeedbackList(pageNum, 2, teacher.getId(), classId, stuName);
    }
}
